﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace eDoc.Controls.User
{
    public partial class ucListUser : System.Web.UI.UserControl
    {
        private string partnerCode = BO.Common.PartnerCode;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            DataTable dt = new DataTable();
            dt = BO.Data.Select_User("0");
            repListUser.DataSource = dt;
            repListUser.DataBind();
        }

        protected void repListUser_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string username = "";
            if (e.CommandName == "delete")
            {
                username = e.CommandArgument.ToString();
                BO.Data.Delete_User(username, partnerCode);
                BindData();
            }
            else if (e.CommandName == "edit")
            {
                username = e.CommandArgument.ToString();
                Session["EditUser"] = username;
                Response.Redirect("/adduser.aspx");
            }
            else if (e.CommandName == "save")
            {
                /*
                HtmlInputHidden t = e.Item.FindControl("firstNameHidden") as HtmlInputHidden;
                Data.Contacts[e.Item.ItemIndex].FirstName = t.Value;
                t = e.Item.FindControl("lastNameHidden") as HtmlInputHidden;
                Data.Contacts[e.Item.ItemIndex].LastName = t.Value;
                EditIndex = -1;
                */
            }

        }


        protected string ReturnTypeUser(string type)
        {
            if (type == "1")
            {
                return "Phi công";
            }
            else if (type == "2")
            {
                return "Tiếp viên";
            }
            else
            {
                return "";
            }
        }
        protected bool CheckVisible(string user)
        {
           

            if (user == "admin")
                return false;

            return true;
        }

    }
}